Skip to content

Exclude notification poll from sliding the idle session timeout#343

Merged
level09 merged 4 commits into
mainfrom
worktree-session-poll-fix
Jul 11, 2026
Merged

Exclude notification poll from sliding the idle session timeout#343
level09 merged 4 commits into
mainfrom
worktree-session-poll-fix

Conversation

@level09

@level09 level09 commented May 23, 2026

Copy link
Copy Markdown
Collaborator

Problem

The session idle timeout (PERMANENT_SESSION_LIFETIME) never fires. The notification poller hits GET /admin/api/notifications every 60s, and with Flask-Session's default SESSION_REFRESH_EACH_REQUEST=True each request rewrites the Redis session TTL back to full lifetime. A user who leaves a tab open is never logged out.

Fix

Mark the automatic poll with an X-Silent-Poll header and override should_set_storage so requests carrying it don't refresh the session expiry (unless they actually modified the session). All other requests, including user actions in the notification drawer, still slide the session.

  • enferno/app.py — per-request opt-out in should_set_storage.
  • enferno/static/js/mixins/notification-mixin.js — only the interval-driven refetchNotifications sends the header; user-initiated loads do not.

Tests

tests/test_session_poll_refresh.py: silent poll leaves the TTL untouched; a normal request still refreshes it.

@level09 level09 requested a review from apodacaduron as a code owner May 23, 2026 11:07
@level09 level09 self-assigned this May 23, 2026
@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a662565d-f99a-45f6-88c0-ef00c3b68a77

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-session-poll-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@apodacaduron apodacaduron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as intended, notifications endpoint no longer refreshes session

@level09 level09 merged commit 6dd6df8 into main Jul 11, 2026
11 checks passed
@level09 level09 deleted the worktree-session-poll-fix branch July 11, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants